using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Konst3d.Efficiency.Suite;

namespace PEM
{
	/// <summary>
	/// Interaction logic for CreateEditMilestoneDialog.xaml
	/// </summary>
	public partial class CreateEditMilestoneDialog : PersistentModalDialog
	{
		public string MilestoneTitle
		{
			get
			{
				return uiMileTitleTextBox.Text;
			}
		}

		public string MilestoneDescription
		{
			get
			{
				return uiMileDescriptionTextBox.Text;
			}
		}

		public DateTime MilestoneDate
		{
			get
			{
				return uiMileDateCalendar.SelectedDate ?? DateTime.Now;
			}
		}

		public CreateEditMilestoneDialog()
		{
			InitializeComponent();
		}

		public bool ShowDialog(Window owner, IMilestone milestone)
		{
			if (milestone != null)
			{
				uiMileTitleTextBox.Text = milestone.Title;
				uiMileDescriptionTextBox.Text = milestone.Description;
				uiMileDateCalendar.SelectedDate = milestone.Date;
			}
			else
			{
				uiMileTitleTextBox.Text = String.Empty;
				uiMileDescriptionTextBox.Text = String.Empty;
				uiMileDateCalendar.SelectedDate = null;
			}

			return ShowDialog(owner);
		}

		private void OnCreateButtonClick(object sender, RoutedEventArgs e)
		{
			DialogResult = true;
		}

		private void OnCancelButtonClick(object sender, RoutedEventArgs e)
		{
			DialogResult = false;
		}
	}
}
